ostree_repo_get_remote_option;
ostree_repo_get_remote_list_option;
ostree_repo_get_remote_boolean_option;
+ ostree_repo_set_cache_dir;
} LIBOSTREE_2016.4;
GFile *tmp_dir;
int tmp_dir_fd;
int cache_dir_fd;
+ char *cache_dir;
GFile *objects_dir;
GFile *state_dir;
int objects_dir_fd;
self->disable_fsync = disable_fsync;
}
+/**
+ * ostree_repo_set_cache_dir:
+ * @self: An #OstreeRepo
+ * @dfd: directory fd
+ * @path: subpath in @dfd
+ *
+ * Set a custom location for the cache directory used for e.g.
+ * per-remote summary caches. Setting this manually is useful when
+ * doing operations on a system repo as a user because you don't have
+ * write permissions in the repo, where the cache is normally stored.
+ */
+gboolean
+ostree_repo_set_cache_dir (OstreeRepo *self,
+ int dfd,
+ const char *path,
+ GCancellable *cancellable,
+ GError **error)
+{
+ int fd;
+
+ if (!glnx_opendirat (dfd, path, TRUE, &fd, error))
+ return FALSE;
+
+ if (self->cache_dir_fd != -1)
+ close (self->cache_dir_fd);
+ self->cache_dir_fd = fd;
+
+ return TRUE;
+}
+
/**
* ostree_repo_get_disable_fsync:
* @self: An #OstreeRepo
void ostree_repo_set_disable_fsync (OstreeRepo *self,
gboolean disable_fsync);
+_OSTREE_PUBLIC
+gboolean ostree_repo_set_cache_dir (OstreeRepo *self,
+ int dfd,
+ const char *path,
+ GCancellable *cancellable,
+ GError **error);
+
_OSTREE_PUBLIC
gboolean ostree_repo_get_disable_fsync (OstreeRepo *self);
static gboolean opt_require_static_deltas;
static gboolean opt_untrusted;
static char* opt_subpath;
+static char* opt_cache_dir;
static int opt_depth = 0;
static GOptionEntry options[] = {
{ "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only, "Fetch only the commit metadata", NULL },
+ { "cache-dir", 0, 0, G_OPTION_ARG_STRING, &opt_cache_dir, "Use custom cache dir", NULL },
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
{ "disable-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_disable_static_deltas, "Do not use static deltas", NULL },
{ "require-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_require_static_deltas, "Require static deltas", NULL },
if (opt_disable_fsync)
ostree_repo_set_disable_fsync (repo, TRUE);
+ if (opt_cache_dir)
+ {
+ if (!ostree_repo_set_cache_dir (repo, AT_FDCWD, opt_cache_dir, cancellable, error))
+ goto out;
+ }
+
if (opt_mirror)
pullflags |= OSTREE_REPO_PULL_FLAGS_MIRROR;
#include "ot-main.h"
#include "ot-remote-builtins.h"
+static char* opt_cache_dir;
+
static GOptionEntry option_entries[] = {
+ { "cache-dir", 0, 0, G_OPTION_ARG_STRING, &opt_cache_dir, "Use custom cache dir", NULL },
};
gboolean
goto out;
}
+ if (opt_cache_dir)
+ {
+ if (!ostree_repo_set_cache_dir (repo, AT_FDCWD, opt_cache_dir, cancellable, error))
+ goto out;
+ }
+
remote_name = argv[1];
if (!ostree_repo_remote_list_refs (repo, remote_name, &refs, cancellable, error))
static gboolean opt_raw;
+static char* opt_cache_dir;
+
static GOptionEntry option_entries[] = {
+ { "cache-dir", 0, 0, G_OPTION_ARG_STRING, &opt_cache_dir, "Use custom cache dir", NULL },
{ "raw", 0, 0, G_OPTION_ARG_NONE, &opt_raw, "Show raw variant data", NULL },
{ NULL }
};
remote_name = argv[1];
+ if (opt_cache_dir)
+ {
+ if (!ostree_repo_set_cache_dir (repo, AT_FDCWD, opt_cache_dir, cancellable, error))
+ goto out;
+ }
+
if (opt_raw)
flags |= OSTREE_DUMP_RAW;
. $(dirname $0)/libtest.sh
-echo "1..6"
+echo "1..7"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
assert_has_file repo/tmp/cache/summaries/origin.sig
echo "ok prune summary cache"
+cd ${test_tmpdir}
+repo_reinit
+mkdir cachedir
+${OSTREE} --repo=repo pull --cache-dir=cachedir origin main
+assert_not_has_file repo/tmp/cache/summaries/origin
+assert_not_has_file repo/tmp/cache/summaries/origin.sig
+assert_has_file cachedir/summaries/origin
+assert_has_file cachedir/summaries/origin.sig
+
+rm cachedir/summaries/origin
+${OSTREE} --repo=repo pull --cache-dir=cachedir origin main
+assert_not_has_file repo/tmp/cache/summaries/origin
+assert_has_file cachedir/summaries/origin
+
+echo "ok pull with signed summary and cachedir"
cd ${test_tmpdir}
repo_reinit